$('.right-titleicon').on("click", function(e) {
	projectVM.showMenulist()
})

projectVM = new Vue({
	el: "#content",
	components: {
		personselect,
		processlog
	},
	data: {
		id: '',
		menuList: [{
			name: '交班',
			path: 'handOver.html'
		}, {
			name: '接班',
			path: 'carryOn.html'
		}, {
			name: '列表',
			path: 'index.html'
		}, ],
		trainId: '',
		drillInfo: [],
		fileList: [],
		drill: [],
		trainingDrill: {},
		phenomenon: [],
		changeValue: '',
		checked: [],
		showSubmit: false,
		onStatus: '',
		result: '',
		showMenu: false,
		showMorebtn: false,
		advance: '',
		showAdd: false,
		show_popup: false,
		list: [{
				content: 'XXX信用XXXX钥匙',
				status: 1,
				user: '[IP123456]张三2021-6-20'
			},
			{
				content: 'XXX信用XXXX钥匙',
				status: 2,
				user: '[IP123456]张三2021-6-20'
			},
			{
				content: 'XXX信用XXXX钥匙',
				status: 3,
				user: '[IP123456]张三2021-6-20'
			}
		],
		backlist: [],
		reviewDict: {},
		fileList: [],
		detailAll: {},
		proscessLogList: [],
		workId: ''
	},
	filters: {
		times: function(dataStr, showhours) {
			var time = new Date(dataStr);

			function timeAdd0(str) {
				if (str < 10) {
					str = '0' + str;
				}
				return str
			}
			var y = time.getFullYear();
			var m = time.getMonth() + 1;
			var d = time.getDate();
			var h = time.getHours();
			var mm = time.getMinutes();
			var s = time.getSeconds();
			if (showhours) {
				return y + '-' + timeAdd0(m) + '-' + timeAdd0(d) + ' ' + timeAdd0(h) + ':' + timeAdd0(mm) +
					':' + timeAdd0(s);
			}
			return y + '-' + timeAdd0(m) + '-' + timeAdd0(d);
		},
		dictFilter(value, dict) {
			if (value && dict) {
				let key = dict.filter((item) => {
					if (item.itemValue == value) {
						return item;
					}
				})
				if (key && key.length) {
					return key[0].itemText;
				}
			}
			return ''
		}
	},
	mounted: function() {
		mui.init()
		mui.plusReady(function() {
			cv = plus.webview.currentWebview();
			projectVM = cv.trainingDrill;
		})
		this.trainingDrill = JSON.parse(localStorage.getItem("trainingDrill"))

		let dictCodes = 'EMERGENCY_BACK_NODES';
		// 获取演练效果评审列表码表
		dictCodes +=
			',ACTIVITY_TYPE,EMERGENCY_DRILL_TYPE,EMERGENCY_OVERALL_APPRAISEINFO,EMERGENCY_SUITABLE_INFO,EMERGENCY_SUFFICIENCY_INFO,EMERGENCY_PERSON_PLACE,EMERGENCY_OVERALL_ORGNIZATION,EMERGENCY_PERSON_PROTECT,EMERGENCY_RESCUE_GROUP,EMERGENCY_PRACTICAL_EFFECT,EMERGENCY_REPORT_SUPERIOR,EMERGENCY_MEDICAL_RESCUE,EMERGENCY_GOVERNMENT_LEAVE,EMERGENCY_MATERIAL_PLACE'

		let dict = mui.neiosCommon.queryDict(dictCodes, (data) => {
			if (data != '') {
				this.backlist = data.EMERGENCY_BACK_NODES;
				this.reviewDict = data;
			}
		})
		this.getDetail()
		this.getFileids();
		this.getNodeListDetail();
	},
	computed: {
		activityTypeShow() {
			// 应急演练显示
			if (this.trainingDrill && this.trainingDrill.activityType == 10) {
				return true;
			} else {
				return false
			}
		}
	},
	methods: {
		// 下载
		downLoad(data) {
			let url = "/app/common/downloadFile";
			let param = {};
			param.fileId = data.fileId;
			mui.neiosCommon.downLoadFile(param, function(ret) {
				mui.plusReady(function() {
					plus.nativeUI.closeWaiting();
				})
				//调用存储
				var callbackID = plus.bridge.callbackId(function(ret) {
					mui.toast(ret[0])
				}, function(err) {
					mui.toast('文件下载失败')
				});
				plus.bridge.execSync("FileHelper", "doFileSave", [callbackID, ret, data.fileName,
					"Argus3", "Argus4"
				])
			}, function(err) {
				mui.plusReady(function() {
					plus.nativeUI.closeWaiting();
				})
				mui.toast('文件下载失败')
			});
		},
		//下载文件
		downloadFile() {
			let url = "/app/common/downloadFile";
			let param = {};
			param.fileId = "1478240333631328258";
			mui.neiosCommon.downLoadFile(param, function(ret) {
				mui.plusReady(function() {
					plus.nativeUI.closeWaiting();
				})
				//调用存储
				var callbackID = plus.bridge.callbackId(function(ret) {
					mui.toast(ret[0])
				}, function(err) {
					mui.toast('文件下载失败')
				});
				plus.bridge.execSync("FileHelper", "doFileSave", [callbackID, ret, "测试.txt", "Argus3",
					"Argus4"
				])
			}, function(err) {
				mui.plusReady(function() {
					plus.nativeUI.closeWaiting();
				})
				mui.toast('文件下载失败')
			});

		},
		//选择上传
		chooesFile() {
			var that = this
			mui.neiosCommon.doUploads(function(ret) {
				if ("0" == ret.code) {
					console.log("成功：" + ret.data.fileName)
					mui.toast('文件' + ret.data.fileName + "上传成功");
				} else {
					mui.toast('文件上传失败');
				}
			}, function(err) {
				mui.toast('文件上传失败');
			})

			let fileArray = that.fileList;
			let data = {
				fileName: "Dingtalk_20211120162759.jpg",
				upLoadDate: "2021-11-20 16:28:10",
				uploadPersion: "张强",
				doOne: ""
			};
			fileArray.push(data)
		},
		//获取文件id
		getFileids() {
			var that = this
			var param = {
				trainingDrillId: this.trainingDrill.trainingDrillId,
				fileUserType: 'base_info'
			}
			mui.neiosRequst.httpRequst('/app/tranEducation/getTrainingFileIds', param,
				function(data) {
					if (data.data != '') {
						that.getFileList(data.data)
					}
				},
				function() {
					console.log("查询失败!");
				}
			);
		},
		//获取文件信息
		getFileList(e) {
			var param = {
				fileIds: e
			}
			var that = this
			mui.neiosRequst.httpRequst('/app/common/getFileList', param,
				function(data) {
					that.fileList = data.data
				},
				function() {
					console.log("查询失败!");
				}
			);
		},
		//获取详情
		getDetail() {
			var that = this
			let param = {
				trainingDrillId: this.trainingDrill.trainingDrillId
			}
			mui.neiosRequst.httpRequst('/app/tranEducation/getDrillByTrainingDrillId', param,
				function(data) {

					that.drill = data.data.drill;
					that.trainingDrill = data.data;
					that.drill.makeTime = mui.neiosCommon.transTime(new Date(that.drill.makeTime), 'day')
					that.drill.reviewTime = mui.neiosCommon.transTime(new Date(that.drill.reviewTime),
						'day')
					that.drillInfo = data.data.drillInfo
					try {
						that.phenomenon = JSON.parse(data.data.drill.phenomenon);
					} catch (e) {
						//TODO handle the exception
					}
					that.detailAll = data.data;
					that.workId = data.data.workId;
					console.log(JSON.stringify(data))
				},
				function() {
					console.log("查询失败!");
				}
			);
		},
		getNodeListDetail() {
			let _this = this;

			mui.neiosRequst.httpRequst('/app/personWork/getNodeLogByWorkId', {
					workId: this.trainingDrill.workId,
					workType: '0302'
				},
				function(data) {

					if (data.code == '0') {
						if (!data.data) {
							_this.proscessLogList = []
						} else {
							_this.proscessLogList = data.data
						}
					} else {
						_this.proscessLogList = []
						mui.toast('请稍后重试！')
					}
					 console.log(JSON.stringify(_this.proscessLogList))
				},
				function(e) {
					_this.proscessLogList = [];

					mui.toast('请稍后重试！')
				}, '0'
			);
		},
		//参与
		join() {
			var btnArray = ['否', '是']
			mui.confirm('是否确定参与?', '确认', btnArray, function(e) {

			})
		},
		//返回上一页
		goBack() {
			mui.back()
		},
		//更多按钮
		showMore() {
			this.showMorebtn ? this.showMorebtn = false : this.showMorebtn = true
		},
		//阻止事件冒泡 
		clickStop() {

		},

		navTo(e) {
			mui.openWindow({
				url: e,
				id: e,
			});
		}
	},

})
